import Vue from 'vue'
import VueRouter from 'vue-router'
import Layout from '@/views/layout/Layout'
import Home from '@/views/Index/Home'

Vue.use(VueRouter)

export default new VueRouter({
    mode: 'hash', // hash history
    routes: [
        {
            path: '/',
            component: Layout,
            children: [
                {
                    path: '/',
                    redirect: '/home'
                },
                {
                    path: 'home',
                    name: 'Home',
                    component: Home
                },
                {
                    path: 'test',
                    name: 'Test',
                    component: resolve => require(['@/views/Index/Test'], resolve)
                }
            ]
        },
        {
            path: '/login',
            name: 'Login',
            component: resolve => require(['@/views/Login'], resolve)
        },
        {
            path: '/error',
            name: 'Error',
            component: resolve => require(['@/views/Error'], resolve)
        },
        /** 404页面 **/
        {
            path: '/404',
            name: 'Nofind',
            component: resolve => require(['@/views/404'], resolve)
        },
        /** 未知页面 **/
        {
            path: '*',
            redirect: '/404'
        }
    ]
})
